package com.aaa.service.impl;

import com.aaa.dao.EmpMapper;
import com.aaa.entity.Emp;
import com.aaa.service.EmpService;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * -*- coding:utf-8 -*-
 *
 * @author 太阳偷渡青山
 * @software IntelliJ IDEA
 * @date 2022/11/19 13:14
 * @Description
 */
@Service
public class EmpServiceImpl extends ServiceImpl<EmpMapper, Emp> implements EmpService {
    @Override
    public Result<Page<Emp>> queryByPageInfo(Integer currentPage, Integer pageSize) {
        //构造分页构造器
        Page<Emp> pageInfo = new Page<>(currentPage, pageSize);

        //构造条件构造器
        LambdaQueryWrapper<Emp> queryWrapper = new LambdaQueryWrapper();
        //添加排序条件
        queryWrapper.orderByDesc(Emp::getId);

        //执行查询
        Page<Emp> page = page(pageInfo, queryWrapper);

        return Result.success(pageInfo);
    }

}
